﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WW.Cad.Model;
using WW.Cad.Base;
using WW.Cad.Drawing;
using WW.Cad.IO;
using WW.Cad.Model.Entities;
using WW.Cad.Model.Objects;
using WW.Cad.Model.Tables;
using WW.Math;
using WW.Math.Geometry;
using System.IO;
using WW.Pdf;

namespace StuertzDatenbank
{


    public partial class Zeichnunganzeigen : Form
    {
        private ViewControl viewcontrol;
        private Sprachfile sprachfile;
        private DxfModel model;
        public Zeichnunganzeigen(DxfModel Model)
        {
            viewcontrol = new ViewControl();
            sprachfile = new Sprachfile();
            model = Model;
            InitializeComponent();
            InitializeComponentChange();
            this.Refresh();
        }

        private void InitializeComponentChange()
        {
            this.Okaybutton.Text = sprachfile.Okay;
            this.button1.Text = sprachfile.Speichern;

            // 
            //Viewcontrol
            // 
            this.viewcontrol.AutoSize = true;
            this.tableLayoutPanel.SetColumnSpan(viewcontrol, 8);
            this.tableLayoutPanel.SetRowSpan(viewcontrol, 8);
            this.viewcontrol.Dock = System.Windows.Forms.DockStyle.Fill;
            this.viewcontrol.Location = new System.Drawing.Point(3, 1);
            this.viewcontrol.Size = new System.Drawing.Size(190, 26);
            this.viewcontrol.TabIndex = 1;
            this.viewcontrol.Visible = true;
            this.tableLayoutPanel.Controls.Add(this.viewcontrol, 0, 0);
            viewcontrol.Model = model;
            viewcontrol.Refresh();

        }

        private void Okaybutton_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.model.Repair();
            this.saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "DXF Datei|*.dxf";
            saveFileDialog1.ShowDialog();

            try
            {
                DxfWriter.Write(this.saveFileDialog1.FileName, this.model);
            }
            catch (Exception)
            {
                
            }
               
            
          



        }

        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {

        }




    }
}
